#include "Statement.h"
#include "Level.h"
#include "../Game.h"
#include "../GraphicManager.h"

bool cStatement::Eval() {
	if (meType == eStatementContent) {
		cLevel &lLevel = cGame::Get().GetLevel();
		return lLevel.IsInCell( macParam1[0], macParam2 );
	}
return false;
}

void cStatement::Do() {
	if (meType != eStatementContent) {
		cGraphicManager & lGraphic = cGraphicManager::Get();
		cLevel &lLevel = cGame::Get().GetLevel();
		cSpecialCellDictionaryIt it;
		cObjectListIt itObject;

		switch (meType) {
			case eStatementRemove:
				lLevel.Remove(macParam1);
				break;
			case eStatementMessage:
				lLevel.SetMessageOn(true);
				lLevel.ResetActionsExecuted();
				lLevel.InsertMessage(macParam1.c_str());
				break;
			case eStatementMove:
				lLevel.LookUp(macParam2.c_str()[0], it);	 
				lLevel.LookUp(macParam1.c_str(), itObject);
				(*itObject)->SetX((*it)->miX);
				(*itObject)->SetY((*it)->miY);
				break;
			case eStatementExit:
				cGame::Get().SetFinished();
				break;
			case eStatementConversation:
				cGame::Get().GetLevel().GetConversationManager().StartConversation(macParam1.c_str());
				break;
		}
	}
}